import axios from '@u/request'
// 请求所有分类
const fetchCates = (params = {}) => {
  return axios.get('/shop/goods/category/all', {params})
}
// 请求首页轮播
const fetchHomeBanner = (params = {}) => {
  return axios.get('/banner/list', {params})
}
// 获取商品列表
const fetchItems = (params = {}) => {
  return axios.post('/shop/goods/list/v2', params)
}
// 获取商品详情 /shop/goods/detail
const fetchItemDetail = (params = {}) => {
  return axios.get('/shop/goods/detail', {params})
}
// 加入购物车接口
const addCart =  (params = {}) => {
  return axios.post('/shopping-cart/add', params)
}
// 用户登录
const doLogin = (params = {}) => {
  return axios.post('/user/username/login', params)
}
// 用户注册
const doRegister = (params = {}) => {
  return axios.post('/user/username/register', params)
}
// 获取用户购物车数据  /shopping-cart/info
const fetchCartInfo = (params = {}) => {
  return axios.get('/shopping-cart/info', {params})
} 
// 增加购物车商品购买数量 /shopping-cart/modifyNumber
const modifyCartNum =  (params = {}) => {
  return axios.post('/shopping-cart/modifyNumber', params)
}
// 删除购物车中商品/shopping-cart/remove
const removeCartItem = (params = {}) => {
  return axios.post('/shopping-cart/remove', params)
}
// 修改购物车商品选中状态 /shopping-cart/select
const modifyCartItemSelected = (params = {}) => {
  return axios.post('/shopping-cart/select', params)
}
export {
  fetchCates,
  fetchHomeBanner,
  fetchItems,
  fetchItemDetail,
  addCart,
  doLogin,
  doRegister,
  fetchCartInfo,
  modifyCartNum,
  removeCartItem,
  modifyCartItemSelected
}